package com.rp.data.tcp_ws.server_tcp.echo;

import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin;

import java.io.IOException;
import java.util.Arrays;

public class SerTest {

    public static void main(String[] args) throws IOException {
//        byte[] bytes = HexBin.decode("40 40 00 00 01 01 39 2D 0F 14 01 13 79 03 00 00 00 00 38 5B 01 00 00 00 00 00 02 B1 23 23".replace(" ", ""));
//        byte[] bytes = HexBin.decode("40 40 00 00 01 01 0C 2F 11 14 01 13 79 03 00 00 00 00 38 5B 01 00 00 00 00 00 03 89 23 23 ".replace(" ", ""));

        //BufferedReader reader = new BufferedReader(new FileReader("/Users/jht/oceancode/firecontrol/document/无锡蓝天/firecontrol-echo.log"));
        String line = null;
//        while ((line = reader.readLine()) != null) {
//            try {
//                if (line.contains("40 40") && line.contains("23 23")) {
//                    line = line.substring(line.indexOf("40"));
//                    if (line.length() > 91) {
//                        byte[] bytes = HexBin.decode(line.replace(" ", ""));
//                        GA26875Decoder.decode(bytes);
//                    }
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//        2019-01-23 21:14:25 [INFO ][firecontrol.echo.GA26875Decoder:189] - 时间:2019-1-23 21:13:15，用户编码:19001，城市代码：21,数据长度:48，命令:2, info:102区8号  反馈 2019-1-23 21:11:0

        //line = "40 40 12 00 01 01 36 17 15 17 01 13 39 4A 00 00 00 00 15 00 00 00 00 00 30 00 02 02 01 01 02 00 08 00 66 00 40 00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 00 00 17 15 17 01 13 36 23 23";
        line = "40400200010104010E150415394A000000001500000000000A00021801040000000E150415422323";
        byte[] bytes = HexBin.decode(line.replace(" ", ""));
        System.out.println(Arrays.toString(GA26875Decoder.decode(bytes)));

    }
}
